#pragma once

#include "BasicType.h"
#include "ShapeStyleDef.h"
#include "Character.h"

namespace LightPlayer{

	enum eShapeRecordType {
		eEndShapeRecord = 0, 
		eStyleChangeRecord = 1,
		eStraightEdgeRecord = 2,
		eCurvedEdgeRecord = 3
	};

	struct SHAPERECORD{
		uint8					m_TypeRecord;
		bool					m_StateNewStyles:1;
		bool					m_StateLineStyle:1;
		bool					m_StateFillStyle1:1;
		bool					m_StateFillStyle0:1;
		bool					m_StateMoveTo:1;
		bool					m_general_line_flag:1;
		bool					m_vertical_line_flag:1;
		uint8					m_FillStyle0;
		uint8					m_FillStyle1;
		uint8					m_LineStyle;
		float					m_MoveDeltaX;
		float					m_MoveDeltaY;
		float					m_ControlDeltaX;
		float					m_ControlDeltaY;
		float					m_AnchorDeltaX;
		float					m_AnchorDeltaY;

		SHAPERECORD();
		void init();
		void readFromStream(Stream* stream, int tag_shape, 
							int& number_fill_bits, int& number_line_bits, 
							int& offset_fill_index, int& offset_line_index, 
							FILLSTYLEARRAY* fillStyles, LINESTYLEARRAY* lineStyles );
	};

	struct SHAPE_NOSTYLE{
		array<SHAPERECORD>		m_ShapeRecords;

		SHAPE_NOSTYLE();
		void init();
		void readFromStream(Stream* stream, int tag_shape = eDefineShape);
	};

	struct SHAPE_WITHSTYLE{
		FILLSTYLEARRAY			m_FillStyles;
		LINESTYLEARRAY			m_LineStyles;
		array<SHAPERECORD>		m_ShapeRecords;

		SHAPE_WITHSTYLE();
		void init();
		void readFromStream(Stream* stream, int tag_shape = eDefineShape, bool is_font_glyph = false);
	};
	
	struct SHAPE_DEFINITION : public Character {
		uint16					m_CharacterId;
		RECT					m_ShapeBounds;
		RECT					m_EdgeBounds;
		bool					m_UseFillWindingRule:1;
		bool					m_UsesNonScalingStrokes:1;
		bool					m_UsesScalingStrokes:1;
		SHAPE_WITHSTYLE			m_ShapeWithStyle;


		SHAPE_DEFINITION();
		void init();
		void readFromStream(Stream* stream, int tag_shape = eDefineShape, bool is_font_glyph = false );
		
		// character interface
		virtual eCharacterType getType() const {return eShapeCharacter;}
		virtual uint16 getCharacterId() const {return m_CharacterId;};
		virtual void draw(LightAbstractRenderer* pRenderer, SceneObject* pInstance);
	};
};